﻿using System;
using System.Collections.Generic;
using System.Text;


//电脑组装
namespace BuilderPattern
{
    //电脑建造抽象类
    public abstract class ComputerBuilder
    {
        public abstract void CpuInstall(Computer pc);
        public abstract void HdInstall(Computer pc);
        public abstract void MemoryInstall(Computer pc);
        public abstract void FanInstall(Computer pc);

        public Computer GetComputer()
        {
            Computer myPc = new Computer();
            CpuInstall(myPc);
            HdInstall(myPc);
            MemoryInstall(myPc);
            FanInstall(myPc);
            return myPc;
        }

    }

    public class LadingPeopleTv : ComputerBuilder
    {
        public override void CpuInstall(Computer pc)
        {
            pc.CPU = "tv model CPU";
        }

        public override void FanInstall(Computer pc)
        {
            pc.Fan = "tv model Fan";
        }

        public override void HdInstall(Computer pc)
        {
            pc.HD = "tv model HD";
        }

        public override void MemoryInstall(Computer pc)
        {
            pc.Memory = "tv model Memory";
        }
    }

    public class LadingPeopleGame : ComputerBuilder
    {

        public override void CpuInstall(Computer pc)
        {
            pc.CPU = "game model CPU";
        }

        public override void FanInstall(Computer pc)
        {
            pc.Fan = "game model Fan";
        }

        public override void HdInstall(Computer pc)
        {
            pc.HD = "game model HD";
        }

        public override void MemoryInstall(Computer pc)
        {
            pc.Memory = "game model Memory";
        }
      
    }

    public class Computer
    {
        public string CPU { get; set; }
        public string HD { get; set; }
        public string Memory { get; set; }
        public string Fan { get; set; }

        public string ShowInfo()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(CPU + "\t");
            sb.Append(HD + "\t");
            sb.Append(Memory+"\t");
            sb.Append(Fan + "\t");
            return sb.ToString();
        }
    }

}
